#!/bin/sh
echo 1qaz2wsx |sudo -v
# 检查是否已配置 8.8.8.8 为 DNS
grep -q "nameserver 8.8.8.8" /etc/resolv.conf
# 如果没有找到 8.8.8.8，添加它
if [ $? -ne 0 ]; then
  echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf > /dev/null
fi
ping -c 1 gitee.com &>/dev/null
# 如果网络不可用，显示红色警告信息并退出
if [ $? -ne 0 ]; then
  echo -e "\033[31mWarning: network is not available, please check your network settings！\033[0m"
  sleep 1s
  exit 1
fi
# 如果网络正常，继续执行后续操作
echo -e "network is ok, continue to update software...\n"
echo 1qaz2wsx | sudo -S rm -rf /home/feibot/platform
cd /home/feibot/ 
git clone  https://gitee.com/feibot/f800-linux-python.git /home/feibot/platform
git config --global credential.helper store
sleep 1s   
chmod 777 -R /home/feibot/platform
git --git-dir /home/feibot/platform/.git checkout master
sleep 1s
chmod 777 -R /home/feibot/platform
sleep 1s
